package controller

import (
	"context"
	"demo_bff/pkg"
	"demo_bff/user_proto"
	"github.com/gin-gonic/gin"
	"net/http"
)

// 用户注册
func UserRegister(c *gin.Context) {
	mobile := c.PostForm("mobile")
	password := c.PostForm("password")
	nickName := c.PostForm("nick_name")
	comment := pkg.Comment()
	register, err := comment.UserRegister(context.Background(), &user_proto.UserRegisterRequest{
		NickName: nickName,
		Mobile:   mobile,
		Password: password,
	})
	if err != nil {
		c.JSON(http.StatusNotFound, gin.H{
			"code": -1,
			"msg":  "注册失败",
			"data": nil,
		})
		return
	}
	c.JSON(http.StatusOK, gin.H{
		"code": 0,
		"msg":  "注册成功",
		"data": register,
	})
	return
}
